package com.siwei.mes.service.system.impl;

import com.siwei.mes.entity.system.SystemConfig;
import com.siwei.mes.mapper.system.SystemConfigMapper;
import com.siwei.mes.service.system.SystemConfigService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import static com.siwei.mes.common.exception.handler.MessageHandler.assertTrue;

/**
 * 系统设置(SystemConfig)表服务实现类
 *
 * @author linzi
 * @since 2024-05-23 21:18:14
 */
@Service
public class SystemConfigServiceImpl implements SystemConfigService {
    @Resource
    private SystemConfigMapper systemConfigMapper;

    @Override
    public void update(SystemConfig entity) {
        SystemConfig systemConfig = systemConfigMapper.selectByPrimaryKey(entity.getId());
        assertTrue(systemConfig == null, "系统设置信息不存在");
        entity.init(false);
        systemConfigMapper.updateByPrimaryKeySelective(entity);
    }

    @Override
    public SystemConfig init() {
        return systemConfigMapper.init();
    }
}
